﻿using System;
using System.Collections.Generic;

namespace NCommet.Core.Exceptions
{
    /// <summary>
    /// <c>ValidationException</c> is an exception thrown when typed tree validation fails.
    /// </summary>
    [Serializable]
    public class ValidationException : CoreException
    {
        /// <summary>
        /// The validation errors, from typed tree validator.
        /// </summary>
        public ICollection<string> ValidationErrors;

        /// <summary>
        /// Creates a new <c>ValidationException</c>.
        /// </summary>
        public ValidationException() : base("Validation Rules Failed.") { }

        /// <summary>
        /// Creates a new <c>ValidationException</c>.
        /// </summary>
        /// <param name="message">The exception message.</param>
        public ValidationException(string message) : base(message) { }

        /// <summary>
        /// Creates a new <c>ValidationException</c>.
        /// </summary>
        /// <param name="message">The exception message.</param>
        /// <param name="inner">The inner exception.</param>
        public ValidationException(string message, Exception inner) : base(message, inner) { }
        protected ValidationException(
          System.Runtime.Serialization.SerializationInfo info,
          System.Runtime.Serialization.StreamingContext context)
            : base(info, context) { }

        /// <summary>
        /// Creates a new <c>ValidationException</c>.
        /// </summary>
        /// <param name="ValidationErrors">A collection of string containing the validation errors.</param>        
        public ValidationException(ICollection<string> ValidationErrors) : this(string.Empty, ValidationErrors, null) { }

        /// <summary>
        /// Creates a new <c>ValidationException</c>.
        /// </summary>
        /// <param name="ValidationErrors">A collection of string containing the validation errors.</param> 
        /// <param name="inner">The inner exception.</param>
        public ValidationException(ICollection<string> ValidationErrors, Exception inner) : this(string.Empty, ValidationErrors, inner) { }

        /// <summary>
        /// Creates a new <c>ValidationException</c>.
        /// </summary>
        /// <param name="message">The exception message.</param>
        /// <param name="ValidationErrors">A collection of string containing the validation errors.</param> 
        /// <param name="inner">The inner exception.</param>
        public ValidationException(string message, ICollection<string> ValidationErrors, Exception inner)
            : base(message, inner)
        {
            this.ValidationErrors = ValidationErrors;
        }
    }
}
